package main

import (
	"bytes"
	"io/ioutil"
	"log"
	"net/http"

	"gitee.com/mdgsf/HTTPUseProtoBuf"
	"github.com/golang/protobuf/proto"
)

func main() {

	money := []int32{1, 2, 3, 4, 5, 6}

	arr := &HTTPUseProtoBuf.MsgArr{}
	arr.Money = money

	data, err := proto.Marshal(arr)
	if err != nil {
		log.Fatal("marshaling error:", err)
	}
	body := bytes.NewBuffer(data)

	url := "http://localhost:9090/protoPostArr"
	contentType := "application/json;charset=utf-8"
	res, err := http.Post(url, contentType, body)
	if err != nil {
		log.Panic("http post failed")
	}

	result, err := ioutil.ReadAll(res.Body)
	res.Body.Close()

	log.Println(result)
	log.Println(string(result))
}
